<!doctype html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<head>
	<title>信息采集</title>
	<link rel="stylesheet" type="text/css" href="css/ch2.basis.css">
	<link rel="stylesheet" type="text/css" href="css/ch2.dialog.css">
	<link rel="stylesheet" type="text/css" href="font/4.2.0/css/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="js/validator-0.7.3/jquery.validator.css">
	<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
	<script type="text/javascript" src="js/ch2.dialog.js"></script>
	<script type="text/javascript" src="js/jsviews.min.js"></script>
	<script type="text/javascript" src="js/ch2.js"></script>
	<script type="text/javascript" src="js/validator-0.7.3/jquery.validator.js"></script>
	<script type="text/javascript" src="js/validator-0.7.3/local/zh_CN.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script>
</head>
<body>
	<div id="header">
		<div class="ctrls"> 
			<a id="window-min" class="win-min" onclick="windowCommand('min')"><i class="fa fa-angle-double-down"></i></a>
        	<a id="window-max" class="win-max" onclick="this.innerHTML = windowCommand('max')?'<i class=&quot;fa fa-compress&quot;></i>':'<i class=&quot;fa fa-expand&quot;></i>';"><i class="fa fa-expand"></i></a>
        	<a id="window-close" class="win-close" onclick="windowCommand('close')"><i class="fa fa-close"></i></a>
		</div>
		<div class="title-bar" onmousedown="windowCommand('drag')"> <span class="title">信息采集</span></div>
	</div> 
	
	<div style="margin:10px;">
		<div class="m-htab m-htab-green m-htab-sm">
			<ul>
				<li><a href="javascript:void(0);" onclick="backList()"><i class="fa fa-list-ol"></i>名册</a></li>
				<li class="z-crt" data-key="btn-group-add"><a href="javascript:void(0);"><i class="fa fa-plus-circle"></i>添加干部信息</a></li>
				<li data-key="btn-group-edit"><a href="javascript:void(0);" onclick="addNew()"><i class="fa fa-plus-circle"></i>添加干部信息</a></li>
				<li class="z-crt" data-key="btn-group-edit"><a href="javascript:void(0);"><i class="fa fa-edit"></i>编辑干部信息</a></li>
			</ul>
		</div>
		<div id="bodyer">
		<h2 style="text-align:center;">市管干部基本情况信息表</h2>
		<form action="/" method="post" class="m-form table-form" id="edit-form">
		<input name="Id" id="Id" type="hidden" value="0" />
		<table class="m-table">
			<tr>
				<td style="width:3em;text-align:center;">姓名</td>
				<td colspan="2"><input id="A0101" name="A0101" type="text" class="u-input" /></td>
				<td style="width:5em;text-align:center;">性别</td>
				<td colspan="2"><select class="u-select" name="A0107" id="A0107"></select></td>
				<td style="width:5em;text-align:center;">出生年月</td>
				<td colspan="2">
					<input name="A0111" id="A0111" type="text" class="u-input" />
				</td>
				<td rowspan="4" style="width:120px;">
				<div id="none-pic">
					相片<br />
（近2年非红底小2寸免冠彩照）
					<br />
					<a href="javascript:void(0);" class="edit-pic"><i class="fa fa-image"></i>选择照片</a>
				</div>
				<div id="has-pic">
					<img title="照片" width="110px;" id="A01C1-img" class="edit-pic">
				</div>
					<input name="A01C1" id="A01C1" type="hidden" value=""/>
				</td>
			</tr>
			<tr>
				<td style="text-align:center;">民族</td>
				<td colspan="2"><select class="u-select" name="A0121" id="A0121"></select></td>
				<td style="text-align:center;">入党<br />时间</td>
				<td colspan="2"><input name="A01CC" id="A01CC" type="text" class="u-input" /></td>
				<td style="text-align:center;">参加工<br />作时间</td>
				<td colspan="2"><input name="A0141" id="A0141" type="text" class="u-input" /></td>
				
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">籍贯</td>
				<td colspan="7">
					<input class="u-input u-input-readonly" readonly type="text" name="A0114-show" id="A0114-show" />
					<input type="hidden" name="A0114" id="A0114" value="" />
				</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">出生地</td>
				<td colspan="7">
					<input class="u-input u-input-readonly" readonly type="text" name="A0117-show" id="A0117-show" />
					<input type="hidden" name="A0117" id="A0117" value="" />
				</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">专业技<br />术职务</td>
				<td colspan="8">
					<input class="u-input u-input-readonly" readonly type="text" name="A01A1005-show" id="A01A1005-show" />
					<input type="hidden" name="A01A1005" id="A01A1005" value="" />
				</td>
			</tr>
			<tr>
				<td rowspan="6" style="text-align:center;">学历</br />学位</td>
				<td rowspan="3" style="text-align:center;">全日制<br />教育</td>
				<td style="text-align:center;">学历</td>
				<td colspan="3">
					<input name="A04.index" type="hidden" value="A" />
					<input name="A04[A].Id" id="A04_A_Id" type="hidden" value="0" />
					<input name="A04[A].DisplayOrder" id="A04_A_DisplayOrder" type="hidden" value="1"/>
					<input name="A04[A].IsDefault" id="A04_A_IsDefault" type="hidden" value="1"/>
					<input name="A04[A].A0449" id="A04_A_A0449" type="hidden" value=""/>
					<select name="A04[A].A0405" id="A04_A_A0405" data-rule="required;" class="u-select"></select>
				</td>
				<td style="text-align:center;">学位</td>
				<td colspan="3">
					<select name="A04[A].A0440" id="A04_A_A0440" data-rule="required;" class="u-select"></select>
				</td>
			</tr>
			<tr>
				<td style="text-align:center;">毕业院校</td>
				<td colspan="7"><input name="A04[A].A0435" id="A04_A_A0435" data-rule="required;" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td style="text-align:center;">专业</td>
				<td colspan="3">
					<input class="u-input u-input-readonly" readonly type="text" name="A04_A_A0410-show" id="A04_A_A0410-show" />
					<input type="hidden" name="A04[A].A0410" data-rule="required;" id="A04_A_A0410" value="" />
				</td>
				<td style="text-align:center;">毕业时间</td>
				<td colspan="3"><input name="A04[A].A0430" id="A04_A_A0430" data-rule="dotdate;" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td rowspan="3" style="text-align:center;">在职<br />教育</td>
				<td style="text-align:center;">学历</td>
				<td colspan="3">
					<input name="A04.index" type="hidden" value="B" />
					<input name="A04[B].Id" id="A04_B_Id" type="hidden" value="0" />
					<input name="A04[B].DisplayOrder" id="A04_B_DisplayOrder" type="hidden" value="1"/>
					<input name="A04[B].IsDefault" id="A04_B_IsDefault" type="hidden" value="2"/>
					<input name="A04[B].A0449" id="A04_B_A0449" type="hidden" value=""/>
					<select name="A04[B].A0405" id="A04_B_A0405" class="u-select"></select>
				</td>
				<td style="text-align:center;">学位</td>
				<td colspan="3">
					<select name="A04[B].A0440" id="A04_B_A0440" class="u-select"></select>
				</td>
			</tr>
			<tr>
				<td style="text-align:center;">毕业院校</td>
				<td colspan="7"><input name="A04[B].A0435" id="A04_B_A0435" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td style="text-align:center;">专业</td>
				<td colspan="3">
					<input class="u-input u-input-readonly" readonly type="text" name="A04_B_A0410-show" id="A04_B_A0410-show" />
					<input type="hidden" name="A04[B].A0410" id="A04_B_A0410" value="" />
				</td>
				<td style="text-align:center;">毕业时间</td>
				<td colspan="3"><input name="A04[B].A0430" id="A04_B_A0430" data-rule="dotdate;" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">身份证号码</td>
				<td colspan="4"><input name="A0177" id="A0177" type="text" class="u-input" /></td>
				<td style="text-align:center;">手机号码</td>
				<td colspan="3"><input name="A01CPhone" id="A01CPhone" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">单位</td>
				<td colspan="4"><input name="A01CUnit" id="A01CUnit" type="text" class="u-input" /></td>
				<td style="text-align:center;">职务</td>
				<td colspan="3"><input name="A01CJob" id="A01CJob" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">分管工作</td>
				<td colspan="8"><input name="A01CWork" id="A01CWork" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td colspan="2" style="text-align:center;">奖励情况<br />(近五年荣获市一级以上奖励)</td>
				<td colspan="8"><textarea rows="5" name="A01CReward" id="A01CReward" class="u-textarea"></textarea></td>
			</tr>
			<tr>
				<td rowspan="7" style="text-align:center;">家庭主要成员<br />及重要社会关系</td>
				<td style="text-align:center;">称谓</td>
				<td style="text-align:center;">姓名</td>
				<td colspan="2" style="text-align:center;">出生年月</td>
				<td colspan="2" style="text-align:center;">政治面貌</td>
				<td colspan="3" style="text-align:center;">工作单位及职务</td>
			</tr>
			<tr>
				<td>
					<input name="A79.index" type="hidden" value="0" />
					<input name="A79[0].Id" id="A79_0_Id" type="hidden" value="0" />
					<select style="width:96%;" class="u-select" name="A79[0].A7910" id="A79_0_A7910"></select>
				</td>
				<td><input name="A79[0].A7905" id="A79_0_A7905" type="text" class="u-input" /></td>
				<td colspan="2"><input name="A79[0].A7915" id="A79_0_A7915" data-rule="dotdate;" type="text" class="u-input" /></td>
				<td colspan="2"><select class="u-select" name="A79[0].A7925" id="A79_0_A7925"></select></td>
				<td colspan="3"><input name="A79[0].A7920" id="A79_0_A7920" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td>
					<input name="A79.index" type="hidden" value="1" />
					<input name="A79[1].Id" id="A79_1_Id" type="hidden" value="0" />
					<select style="width:96%;" class="u-select" name="A79[1].A7910" id="A79_1_A7910"></select>
				</td>
				<td><input name="A79[1].A7905" id="A79_1_A7905" type="text" class="u-input" /></td>
				<td colspan="2"><input name="A79[1].A7915" id="A79_1_A7915" data-rule="dotdate;" type="text" class="u-input" /></td>
				<td colspan="2"><select class="u-select" name="A79[1].A7925" id="A79_1_A7925"></select></td>
				<td colspan="3"><input name="A79[1].A7920" id="A79_1_A7920" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td>
					<input name="A79.index" type="hidden" value="2" />
					<input name="A79[2].Id" id="A79_2_Id" type="hidden" value="0" />
					<select style="width:96%;" class="u-select" name="A79[2].A7910" id="A79_2_A7910"></select>
				</td>
				<td><input name="A79[2].A7905" id="A79_2_A7905" type="text" class="u-input" /></td>
				<td colspan="2"><input name="A79[2].A7915" id="A79_2_A7915" data-rule="dotdate;" type="text" class="u-input" /></td>
				<td colspan="2"><select class="u-select" name="A79[2].A7925" id="A79_2_A7925"></select></td>
				<td colspan="3"><input name="A79[2].A7920" id="A79_2_A7920" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td>
					<input name="A79.index" type="hidden" value="3" />
					<input name="A79[3].Id" id="A79_3_Id" type="hidden" value="0" />
					<select style="width:96%;" class="u-select" name="A79[3].A7910" id="A79_3_A7910"></select>
				</td>
				<td><input name="A79[3].A7905" id="A79_3_A7905" type="text" class="u-input" /></td>
				<td colspan="2"><input name="A79[3].A7915" id="A79_3_A7915" data-rule="dotdate;" type="text" class="u-input" /></td>
				<td colspan="2"><select class="u-select" name="A79[3].A7925" id="A79_3_A7925"></select></td>
				<td colspan="3"><input name="A79[3].A7920" id="A79_3_A7920" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td>
					<input name="A79.index" type="hidden" value="4" />
					<input name="A79[4].Id" id="A79_4_Id" type="hidden" value="0" />
					<select style="width:96%;" class="u-select" name="A79[4].A7910" id="A79_4_A7910"></select>
				</td>
				<td><input name="A79[4].A7905" id="A79_4_A7905" type="text" class="u-input" /></td>
				<td colspan="2"><input name="A79[4].A7915" id="A79_4_A7915" data-rule="dotdate;" type="text" class="u-input" /></td>
				<td colspan="2"><select class="u-select" name="A79[4].A7925" id="A79_4_A7925"></select></td>
				<td colspan="3"><input name="A79[4].A7920" id="A79_4_A7920" type="text" class="u-input" /></td>
			</tr>
			<tr>
				<td>
					<input name="A79.index" type="hidden" value="5" />
					<input name="A79[5].Id" id="A79_5_Id" type="hidden" value="0" />
					<select style="width:96%;" class="u-select" name="A79[5].A7910" id="A79_5_A7910"></select>
				</td>
				<td><input name="A79[5].A7905" id="A79_5_A7905" type="text" class="u-input" /></td>
				<td colspan="2"><input name="A79[5].A7915" id="A79_5_A7915" data-rule="dotdate;" type="text" class="u-input" /></td>
				<td colspan="2"><select class="u-select" name="A79[5].A7925" id="A79_5_A7925"></select></td>
				<td colspan="3"><input name="A79[5].A7920" id="A79_5_A7920" type="text" class="u-input" /></td>
			</tr>
		</table>
		<input name="isedit" id="isedit" type="hidden" value="0" />
		</form>
		<div id="A0114-dlg"></div>
		<div id="A0117-dlg"></div>
		<div id="A01A1005-dlg"></div>
		<div id="A04_A_A0410-dlg"></div>
		<div id="A04_B_A0410-dlg"></div>
	</div>
	<div style="text-align:right;" class="u-mt10">
		<button class="u-btn u-btn-green" type="button" id="save-btn"><i class="fa fa-save"></i>保存信息</button>
	</div>
	</div>
	
	<script type="text/javascript">
		$(function(){
			var $form=$('#edit-form');
			$form.validator({
				theme:'yellow_top',
				rules:{
					dotdate:[/^\d{4}.[0-9]{1,2}$/,'格式如：1970.03'],
					idcard:[/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}[0-9|x|X]$/,'请输入正确的身份证号码.'],
					mobile:[/^\d{11}$/,'手机号码为11位.']
				},
    			messages: {
        			required: "请填写{0}"
    			},
    			fields: {
        			A0101: 'required',
        			A0107: 'required',
        			A0111: 'required;dotdate',
        			A0141: 'required;dotdate',
        			A0177: 'required;idcard',
        			A01CC: 'required;dotdate',
        			A01CUnit: 'required',
        			A01CJob: 'required',
        			A01CPhone: 'required;mobile',
        			A0121: 'required',
        			A0114: 'required',
        			A0117: 'required'
    			}
			});
			var id=external.editId;
			var model=external.model;
			if(id){
				$('[data-key="btn-group-add"]').hide();
				$('#isedit').val(1);
			}else{
				$('[data-key="btn-group-edit"]').hide();
				$('#isedit').val(0);
			}
			
			var setModel=function(model){
				$('#Id').val(model.Id);
				$('#A0101').val(model.A0101);
				$('#A0111').val(model.A0111);
				$('#A0141').val(model.A0141);
				$('#A0177').val(model.A0177);
				$('#A01CC').val(model.A01CC);
				$('#A01CUnit').val(model.A01CUnit);
				$('#A01CReward').val(model.A01CReward);
				$('#A01CJob').val(model.A01CJob);
				$('#A01CWork').val(model.A01CWork);
				$('#A01CPhone').val(model.A01CPhone);
				$('#A0107').StandardSelect({
					source:getStandards('GBT2261.1'),
					value:model.A0107
				});
				$('#A0121').StandardSelect({
					source:getStandards('GBT3304'),
					value:model.A0121
				});
				$('#A0114-show').GBT2260Dialog({
					title:'籍贯',
					value:model.A0114
				});
				$('#A0117-show').GBT2260Dialog({
					title:'出生地',
					value:model.A0117
				});
				$('#A01A1005-show').StandardDialog({
					title:'专业技术职务',
					value:model.A01A1005,
					code:'GBT8561'
				});
				//A04
				$.each(['A','B'],function(ai,ae){
					var entity={
						A0410:'',
						A0405:'',
						A0440:'',
						A0449:'',
						A0435:'',
						A0430:'',
						Id:'0',
						DisplayOrder:ai+1,
						IsDefault:1
					};
					var a04Item=model.A04?model.A04[ai]?model.A04[ai]:entity:entity;
                    $('#A04_'+ae+'_A0410-show').StandardDialog({
                        code:'GBT16835',
                        value:a04Item.A0410,
                        title:'专业',
                        canself:true
                    });
                    $('#A04_'+ae+'_A0405').StandardSelect({
                        source:getStandards('GBT4658'),
                        value:a04Item.A0405
                    });
                    $('#A04_'+ae+'_A0440').StandardSelect({
                        source:getStandards('GBT6864'),
                        value:a04Item.A0440
                    });
                    $('#A04_'+ae+'_A0449').val(a04Item.A0449);
                    $('#A04_'+ae+'_A0435').val(a04Item.A0435);
                    $('#A04_'+ae+'_A0430').val(a04Item.A0430);
                    $('#A04_'+ae+'_Id').val(a04Item.Id);
                    $('#A04_'+ae+'_DisplayOrder').val(a04Item.DisplayOrder);
                    $('#A04_'+ae+'_IsDefault').val(a04Item.IsDefault);
                });
				//A79
                $.each(['0','1','2','3','4','5'],function(ai,ae){
                	var entity={
                		A7910:'',
                		A7925:'',
                		Id:'0',
                		A7905:'',
                		A7915:'',
                		A7920:''
                	};
                	var modelItem=model.A79?model.A79[ai]?model.A79[ai]:entity:entity;
                    $('#A79_'+ae+'_A7910').StandardSelect({
                        source:getStandards('GBT4761'),
                        value:modelItem.A7910
                    });
                    $('#A79_'+ae+'_A7925').StandardSelect({
                        source:getStandards('GBT4762'),
                        value:modelItem.A7925
                    });
                    $('#A79_'+ae+'_Id').val(modelItem.Id);
                    $('#A79_'+ae+'_A7905').val(modelItem.A7905);
                    $('#A79_'+ae+'_A7915').val(modelItem.A7915);
                    $('#A79_'+ae+'_A7920').val(modelItem.A7920);
                });
			};
			setModel(model);
			var Pic=getPic(id);
			if (Pic) {
				$('#has-pic').show();
				$('#none-pic').hide();
				$('#has-pic').find('img').attr('src',decodeURI(Pic));
			}else{
				$('#has-pic').hide();
				$('#none-pic').show();
			}
			//alert(external.alertMSG('dsds'));
			//$("#sId").text(external.editId);

			$('#save-btn').on('click',function(){
					$form.trigger("validate");
					$form.isValid(function(v){
    				if (!v) {
						$.ch2Alert('请按提示正确填写信息！');
    				}else{
    					var data=$.UrlHelper.getObject($form.serialize());
						var id=postModel(data);
						if(id){
							$.ch2Info('保存成功!',[
								{
									text:'返回列表',
									iconClassName:'fa-list-ol',
									className:'u-btn-green',
									handler:function(b,m){
										backList();
									}
								},{
									text:'继续编辑',
									iconClassName:'fa-edit',
									className:'u-btn-blue',
									handler:function(b,m){
										editCommand(id);
									}
								}
							]);
						}else{
							$.ch2Alert('保存失败!');
						}
    				}
				});
					
			});

			$('.edit-pic').on('click',function(){
				var id=$('#Id').val();
				if (id==0) {
					$.ch2Alert('请先保存基本信息再选择照片!','提示信息');
				}else{
					$.blockUI({message:'正在加入照片...'});
					var result=selectPic(id);
					//alert(decodeURI(JSON.stringify(result)));
					if(result.success){
						$.unblockUI();
						$('#has-pic').show();
						$('#none-pic').hide();
						var imageB64=decodeURI(result.imgstr);
						$("#A01C1").val("data:image/jpg;base64,"+imageB64);
						$('#A01C1-img').attr('src',"data:image/jpg;base64,"+imageB64);
						$.ch2Alert(result.message);
					}else{
						$.unblockUI();
						$.ch2Alert(result.message);
					}
				}
			});
		});
	</script>
</body>
</html>